package frame;

import global.Const;
import panel.common.SearchField;
import panel.common.TextField;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class SearchUser extends JFrame implements ActionListener {
    public SearchUser() {
        init();
    }

    private void init() {
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        setSize(Const.WINDOW_WIDTH+Const.WIDTH_ERROE, Const.WINDOW_HEIGHT+Const.HEIGHT_ERROE+64);
        setLocationRelativeTo(null);
        setTitle("查找用户");
        setResizable(false);
        setBackground(Color.white);
        setLayout(null);

        SearchField username = new SearchField("用户名");
        username.setBounds(-5, 0, getWidth()-Const.WIDTH_ERROE+10, 64);
        username.searchButton.addActionListener(e -> searchUser());

        // 添加组件
        add(username);

        // 启动
        setVisible(true);
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        System.out.println(e.getActionCommand());
        switch (e.getActionCommand()) {
            case "查找用户":
                new SearchUser();
                break;
        }
    }

    private void searchUser() {

    }
}
